package com.bustle.user.dto.authentication;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import com.bustle.commons.MapConverter;
import com.bustle.user.data.Authentication;
import com.bustle.user.dto.user.DtoToUserMapConverter;

@Local
public interface DtoToAuthenticationMapConverter extends MapConverter<AuthenticationDto, Authentication>
{
  @Stateless
  public class DefaultDtoToAuthenticationMapConverter extends AbstractMapConverter<AuthenticationDto, Authentication> implements DtoToAuthenticationMapConverter
  {
    @Override
    protected void doMapping(AuthenticationDto aSource, Authentication aDestination)
    {
      aDestination.setLogin(aSource.getLogin());
      aDestination.setPassword(aSource.getPassword());
      aDestination.setUser(dtoToUserConverter.map(aSource.getUser(), aDestination.getUser()));
    }

    @Override
    protected Authentication build()
    {
      return new Authentication();
    }

    @EJB
    protected DtoToUserMapConverter dtoToUserConverter;
  }
}